#ifndef _BIGNMBR_H
#define _BIGNMBR_H

struct bignum_st;

class DLL_EXPORT BigNumber
{
	public:
		BigNumber();
		BigNumber(const BigNumber& bn);
		BigNumber(ui32);
		~BigNumber();

		void SetDword(ui32);
		void SetQword(ui64);
		void SetBinary(const ui8* bytes, int len);
		void SetHexStr(const char* str);

		void SetRand(int numbits);

		BigNumber operator=(const BigNumber& bn);

		BigNumber operator+=(const BigNumber &bn);
		BigNumber operator+(const BigNumber &bn) {
			BigNumber t(*this);
			return t += bn;
		}
		BigNumber operator-=(const BigNumber& bn);
		BigNumber operator-(const BigNumber& bn) {
			BigNumber t(*this);
			return t -= bn;
		}
		BigNumber operator*=(const BigNumber& bn);
		BigNumber operator*(const BigNumber& bn) {
			BigNumber t(*this);
			return t *= bn;
		}
		BigNumber operator/=(const BigNumber& bn);
		BigNumber operator/(const BigNumber& bn) {
			BigNumber t(*this);
			return t /= bn;
		}
		BigNumber operator%=(const BigNumber& bn);
		BigNumber operator%(const BigNumber& bn) {
			BigNumber t(*this);
			return t %= bn;
		}

		BigNumber ModExp(const BigNumber& bn1, const BigNumber& bn2);
		BigNumber Exp(const BigNumber&);

		int GetNumBytes(void);

		struct bignum_st *BN() { return _bn; }

		ui32 AsDword();
		ui8* AsByteArray();

		const char* AsHexStr();
		const char* AsDecStr();

	private:
		struct bignum_st* _bn;
		ui8* _array;
};

#endif